<html>
<head>
    <script src="/jquery-2.2.3.min.js"></script>
    <script src="/method.js"></script>
</head>
<body>
<table >
用 户 名:<input type="text" id="username"/></br>
密   码:<input type="password" id="password"/></br>
<input type="button" id="login" value="登录" onclick="login()"/>
</table>
<script>
    function login() {
        var userName = $("#username").val();
        var password =  $("#password").val();
        // 校验内容
        if(userName == ""  ) {
            alert("用户名不能为空");
            return ;
        }
        if(password == "") {
            alert("密码不能为空");
            return ;
        }
        var url = "/login/dologin" ;
        var data = {
            userName:userName,
            password:password
        } ;
        postReq(url,data,function (result) {
            if(result.success) {
                alert("登陆成功");
                $("#username").val("");
                $("#password").val("");
                location.href='/index';
            } else {
                alert("登录失败："+ result.msg);
            }
        }) ;
    }
</script>
</body>
</html>